ValueFolderTemp='/sps/isc/rneveu/EtudeIRM/Nature/ResultsJournal/';
VecValueResults=[];
VecValueResults2=[];
VecValueResults3=[];
ValueThreshold=[0.1 50];
for n1=1:33
    n1
    load([ValueFolderTemp 'ResultsJournalTemp' num2str(n1) '.mat']);
    VecValueResultsTemp=NaN(size(VecResults,1),1);
    VecValueResultsTemp3=NaN(size(VecResults,1),1);
    for n2=1:size(VecResults,1)
        VecValueResultsTemp(n2,1)=size(VecResults{n2,7},1);
        ValueTemp=VecResults{n2,1};
        if strcmpi(ValueTemp,'et al.')==1||strcmpi(ValueTemp,'et al')==1||strcmpi(ValueTemp,'al. et')==1||strcmpi(ValueTemp,'al et')==1
            VecValueResultsTemp3(n2,1)=1;
        else
            VecValueResultsTemp3(n2,1)=0;
        end
    end
    ValueTemp=find(VecValueResultsTemp3==1);
    if size(ValueTemp,1)>=1
        VecValueResults3=[VecValueResults3;n1*ones(size(ValueTemp,1),1) VecValueResultsTemp(ValueTemp,1) max(VecValueResultsTemp)*ones(size(ValueTemp,1),1)];
    end
    if sum(VecValueResultsTemp)>ValueThreshold(1,2)
        ValueTemp=find(VecValueResultsTemp<sum(VecValueResultsTemp)*ValueThreshold(1,1)&VecValueResultsTemp<ValueThreshold(1,2));
        ValueTemp2=find(VecValueResultsTemp>=sum(VecValueResultsTemp)*ValueThreshold(1,1)|VecValueResultsTemp>=ValueThreshold(1,2));
        VecOutliersTemp=[size(VecResults,1) size(ValueTemp2,1) sum(VecValueResultsTemp) VecValueResultsTemp(ValueTemp2,1)'];
        VecOutliers=VecResults(ValueTemp2,:);
        VecValueResultsTemp=VecValueResultsTemp(ValueTemp,1);
        if size(VecValueResultsTemp,1)>=1
            VecValueResults=[VecValueResults;mean(VecValueResultsTemp) median(VecValueResultsTemp) quantile(VecValueResultsTemp,0.99) min(VecValueResultsTemp) max(VecValueResultsTemp) sum(VecValueResultsTemp)];
        else
            VecValueResults=[VecValueResults;mean(VecValueResultsTemp) median(VecValueResultsTemp) NaN NaN NaN 0];
        end
        VecResults=VecResults(ValueTemp,:);
    end
%     VecValueResults2=[];
%     for n2=1:size(VecResults,1)
%         VecValueTemp=VecResults{n2,2};
%         for n3=1:size(VecValueTemp,1)
%             ValueTemp=VecValueTemp(n3,:);
%             TestTemp=0;
%             n4=1;
%             while n4<=size(VecResults,1)&&TestTemp==0
%                 if n4~=n2
%                     VecValueTemp2=VecResults{n4,2};
%                     ValueTemp2=find(VecValueTemp2(:,1)==ValueTemp(1,1)&VecValueTemp2(:,2)==ValueTemp(1,2));
%                     if size(ValueTemp2,1)>=1
%                         TestTemp=1;
%                     end
%                 end
%                 n4=n4+1;
%             end
%             VecValueResults2=[VecValueResults2;TestTemp];
%         end
%     end
    save([ValueFolderTemp 'ResultsJournalTempFiltered' num2str(n1) '.mat'],'VecResults','ValueThreshold','VecOutliers');
end

% % Check if the authors extraction within each journal did not lead to authors without any name
% VecValueResultsTemp3=[];
% for n1=1:33
%     n1
%     load([ValueFolderTemp 'ResultsJournal' num2str(n1) '.mat']);
%     VecValueResultsTemp2=[];
%     for n2=1860:2020
%         eval(sprintf('VecResults=VecResultsArticle%d;',n2));
%         VecValueResultsTemp=NaN(size(VecResults,1),1);
%         for n3=1:size(VecResults,1)
%             VecValueResultsTemp(n3,1)=size(VecResults{n3,1},2);
%         end
%         VecValueResultsTemp2=[VecValueResultsTemp2;VecValueResultsTemp];
%     end
%     ValueTemp=find(VecValueResultsTemp2==0);
%     VecValueResultsTemp3=[VecValueResultsTemp3;size(ValueTemp,1) size(VecValueResultsTemp2)];
% end